/*
 * @Author: lwh
 * @Date: 2024-01-25 09:07:37
 * @LastEditTime: 2024-01-31 21:12:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 */
$(document).ready(function() {
  var countdownDate = new Date("2024-02-01T08:00:00Z");

  function checkLoginAvailability() {
    var now = new Date();
    if (now < countdownDate) {
      var timeDiff = countdownDate - now;
      var hours = Math.floor(timeDiff / (1000 * 60 * 60));
      var minutes = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60));
      var seconds = Math.floor((timeDiff % (1000 * 60)) / 1000);

      var content = "还没有到特定时间，距离登录时间还剩 " +
                    hours + " 时 " +
                    minutes + " 分 " +
                    seconds + " 秒";
      
      alert(content);
    } else {
      var userName = $("#userName").val();
      var pwd = $("#pwd").val();
      if (userName === "duanlinchuan" && pwd === "duanlinchuanhappybirthday") {
        $(".form").fadeOut(1000);
        $(".wrapper").addClass("form-success");
        setTimeout(function() {
          location.href = "BirthdayCake.html";
        }, 2000);
      } else {
        showModal("账号或密码错误");
      }
    }
  }

  function showModal(content) {
    $("#modal-content").text(content);
    $("#custom-modal").modal("show");
  }

  $("#login-button").click(function(event) {
    event.preventDefault(); // 阻止按钮默认行为
    checkLoginAvailability();
  });
});